package com.example.lol.ui;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.lol.R;
import com.example.lol.ui.adapter.NewsAdapter;
import com.example.lol.ui.bean.NewBean;
import java.util.ArrayList;
import java.util.List;

public class ThirdHomeFragment extends Fragment {
    private String[] title = new String[]{"LPL春季赛3月8日首发名单，Xiaohu上路交手zs",
            "【反向解说42】重铸AD荣光 Xiaohu义不容辞！",
            "新忍村大战————————IGvsTES复盘",
            "震惊！宁波工程学院一男子李少波半夜竟然开直播做了这事",
            "李少波为什么一个人？他的感情生活是否依旧丰富多彩？"
    };
    private int[] cover = new int[]{R.drawable.zyxs_4,
            R.drawable.zyxs_5,
            R.drawable.zyxs_3,
            R.drawable.zyxs_1,
            R.drawable.zyxs_2};

    private String[] hot = new String[]{"英雄联盟官方","聒噪的山海君","小哇哇哇哇哇","走进去李少波","lsbd情感故事"};
    private String[] number = new String[]{"99","44","33","22","11"};
    private List<NewBean> initData() {
        List<NewBean> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            list.add(new NewBean()
                    .setTitle(title[i % title.length])
                    .setHot(hot[i % title.length])
                    .setDrawable(cover[i % cover.length])
                    .setLol(R.drawable.ic_lol_icon)
                    .setIcon(R.drawable.ic_chat)
                    .setNumber(number[i % title.length])
            );
        }
        return list;
    }
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home_2, container, false);
        RecyclerView textView = view.findViewById(R.id.tv_text);
        textView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        NewsAdapter newsAdapter=new NewsAdapter();
        newsAdapter.setList(initData());
        textView.setAdapter(newsAdapter);
        return view;
    }
}